package net.sourceforge.m2settings;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.Reader;
import java.io.Writer;

import org.exolab.castor.xml.MarshalException;
import org.exolab.castor.xml.Marshaller;
import org.exolab.castor.xml.Unmarshaller;
import org.exolab.castor.xml.ValidationException;
import org.xml.sax.InputSource;

import net.sourceforge.m2settings.model.Settings;

public class SettingsXMLFileBinder extends SettingsXMLBinder {
	private File settingsFile;
	
	public SettingsXMLFileBinder(File settingsDotXML) throws FileNotFoundException, MarshalException, ValidationException {
		settingsFile=settingsDotXML;
		loadSettings();
	}
	
	public void loadSettings() throws FileNotFoundException, MarshalException, ValidationException {
		FileReader fr=new FileReader(settingsFile);
		readSettings(fr);
	}
	
	
	public void saveSettings() throws IOException, MarshalException, ValidationException {
		FileWriter fw=new FileWriter(settingsFile);
		writeSettings(fw);
	}
}
